package com.wwf.myblog.service.impl;

import com.wwf.myblog.dao.IArticleDao;
import com.wwf.myblog.pojo.Article;
import com.wwf.myblog.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements IArticleService {
    @Autowired
    IArticleDao articleDao;
    @Override
    public Page<Article> pageAllArticles(Integer pagesize, Integer pagenum) {
        PageRequest pageRequest = PageRequest.of(pagenum-1, pagesize, Sort.by(Sort.Direction.DESC,"id"));
        Page<Article> all = articleDao.findAll(pageRequest);
        return all;
    }
}
